/*
 * object.h
 *
 *  Created on: 26-Apr-2009
 *      Author: catchthealien
 */

#ifndef OBJECT_H_
#define OBJECT_H_

#include <stdio.h>
#include <iostream>
#include <crystalspace.h>

namespace cta {

class object {
public:
	csVector3 position3d_;

	csRef<iTextureWrapper> image_;
	csRef<iMaterialWrapper> material_;
	csRef<iMeshFactoryWrapper> model_;
	csRef<iMeshWrapper> mesh_;
	csRef<iSprite3DState> sprstate;

	csVector3 velocity_;
private:
	// Name
	std::string id_;
	//
	float width_;
	float height_;
	float length_;
	float mass_;
public:
	float velocity_max_;
	float acceleration_max_;
private:
	csVector3 acceleration_;
	//
	//std::string ObjectFile_;
	//std::string PackageFile_;
	std::string ModelName_;
	std::string ModelPackage_;
	std::string TextureName_;
	std::string TexturePackage_;

public:
	object();
	object(std::string &ObjectName, std::string &PackageName);
	object(char* ObjectName, char* PackageName);
	virtual ~object();
	virtual bool Draw();
	virtual bool LoadPackage(std::string ObjectName, std::string PackageName);
	virtual bool LoadPackage(char* ObjectName, char* PackageName);
	virtual bool LoadZipArchive(std::string &ObjectName, std::string &PackageName);
	virtual bool LoadXMLFile(std::string &ObjectName, std::string &PackageName);
	virtual bool LoadXMLFile(std::string &FileName);
	virtual bool LoadModel(std::string &FileName, std::string &PackageName);
	virtual bool LoadTexture(std::string &FileName, std::string &PackageName);
	virtual bool SetObjectPosition(csVector3 position);
	virtual bool Remove();
	virtual bool Command(std::string command_);


    std::string getId() const
    {
        return id_;
    }

    void setId(std::string id_)
    {
        this->id_ = id_;
    }

    csRef<iMeshWrapper> getMesh() const
    {
        return mesh_;
    }

    void setMesh(csRef<iMeshWrapper> mesh_)
    {
        this->mesh_ = mesh_;
    }

    //virtual iTextureWrapper *getImage() const
    //{
    //    return image_;
    //}

    //virtual bool setImage(std::string ImageFile);

    float getVelocity_max() const
    {
        return velocity_max_;
    }

    float getAcceleration_max() const
    {
        return acceleration_max_;
    }

    csVector3 getVelocity() const
    {
        return velocity_;
    }

    void setVelocity(csVector3 velocity_)
    {
        this->velocity_ = velocity_;
    }

    csVector3 getPosition3d()
    {
    	position3d_ = mesh_->GetMovable()->GetPosition();
        return position3d_;
    }

    void setPosition3d(csVector3 position3d__)
    {
        this->position3d_ = position3d__;
        SetObjectPosition(position3d__);
    }

    //irr::core::position2di getPosition2d() const
    //{
    //    return position2d_;
    //}

    //virtual void setPosition2d(irr::core::position2di position2d__)
    //{
    //    position2d_ = position2d__;
    //}

};

}

#endif /* OBJECT_H_ */
